import axios from 'axios'

// 文件上传
export interface BpmnUploader {
	xml: string

	name: string
}

/**
 * 实体接口
 */
export interface Definition {
	current: number

	pageSize: number
}

/**
 * 提交流程定义
 */
export function saveProcessDefinition(data: BpmnUploader) {
	return axios.post('/process-definition/online-deployment', data)
}

/**
 * 上传Bpmn文件
 */
export function uploadBpmnFile(data: FormData) {
	return axios.post('/process-definition/upload', data)
}

/**
 * 获取流程定义列表（分页）
 */
export function getProcessDefinitionList(params: Definition) {
	return axios.get('/process-definition/list', { params })
}

/**
 * 根据流程定义ID和资源名获取XML
 */
export function getProcessDefinitionXml(params: {
	deploymentId: string
	resourceName: string
}) {
	return axios.get('/process-definition/xml', { params })
}

/**
 * 删除流程实例
 */
export function deleteProcessDefinition(processDefinitionId: string) {
	return axios.delete(`/process-definition/${processDefinitionId}`)
}